new Vue({
	el: '.vuedata',
	data() {
		return {
			ip: IPCMS,
			listurl: "/index.php/api/Notes",
			mark: 0, //比对图片索引的变量
			list: [], //新闻列表
			page: 1, //文章页数
			flag: true,
			longtext: "加载中",
			columnArrId: [],

		}
	},
	methods: {
		//页面跳转
		htmlgo(url) {
			window.location.href = "nots.html?id=" + url;
		},
		/**
		 * 获取文章列表
		 */
		listData() {
			var http = this.ip + this.listurl;
			this.$http.jsonp(http, {
				params: {
					"page": this.page,
					"cid": this.columnArrId,
					"per_page": 10
				}
			}).then(res => {
				var body = res.body;
				console.log(body);
				var data = body.result;
				if(data.length > 0) {
					//					data.forEach(e=>{
					//						e.add_time=this.formartDate(e.add.time);
					//					});
					if(this.list.length == 0||this.list.length<10) {
						this.list = data;
					} else {
						this.list = this.list.concat(data);
					}
					this.flag = true;
					this.longtext = "加载更多";
				} else {
					this.flag = false;
					this.longtext = "没有更多了";
				}

			}).catch(res => {
				console.log("请求出错");
				this.flag = false;
				this.longtext = "请求错误，请刷新重试";
			})
		},
		/**
		 * 加载更多
		 */
		onloading() {
			if(this.flag) {
				this.flag = false;
				this.longtext = "加载中";
				if(this.list.length>10){
					this.page = this.page + 1;
				}				
				console.log("ccc");
				//			            modal.toast({ message: 'loading', duration: 1 })
				setTimeout(() => {
					this.listData();
				}, 1500)
			}
			console.log("执行");
		},
		//时间格式
		timestampToTime(timestamp) {
				return pub.timestampToTime(timestamp);
		
		},
		//字符串过长截取
		subst(data,n) {
			var num = n;
			return pub.substdata(data,num);
		},

	},
	created() {
		this.listData();
	},

})

new Vue({
	el:".go",
	methods:{
		/**
		 * 返回上一页
		 */
		histroygo(){
			history.go(-1);
		},
	}
})